<template>
  <div>
    <div v-for="(item,index) in allTongz" :key="index">
      <div v-if="item.data_id==items" class="NotificationDetails_die">
        <div class="header">
          <img src="http://www.zhaoshengku.net/wx-tuoyuantwoxiaoxi.png" alt />
          <span>{{item.notice_title}}</span>
        </div>
        <div class="content">
          <wxParse :content="item.notice_content"></wxParse>
        </div>
        <div class="times">{{item.data_add_time}}</div>
      </div>
    </div>
  </div>
</template>

<script>
import wxParse from "mpvue-wxparse";
export default {
  components: {
    wxParse
  },
  data() {
    return {
      items: -1,
      allTongz: [],
      indexs: -1
    };
  },
  onLoad(option) {
    this.items = option.id;
    wx.getStorage({
      key: "koken",
      success: res => {
        this.headerCode = "Bearer " + res.data;
        wx.request({
          url: "https://api.zhaoshengku.net/index/notice/getnotice",
          method: "post",
          data: {
            pagenum: 1,
            pagesize: 10
          },
          header: {
            Authorization: this.headerCode,
            "X-Requested-With": "xmlhttprequest"
          },
          success: res => {
            this.allTongz = res.data.data.data;
            this.allTongz.forEach(element => {
              element.data_add_time = element.data_add_time.substring(0, 10);
            });
          },
          fail: res => {
          console.log(res);
          if (res.errMsg) {
            wx.showToast({
              title: "请检查网络连接！",
              icon: "none",
              duration: 1500
            });
          }
        }
        });
        wx.request({
          url: "https://api.zhaoshengku.net/index/notice/readnotice",
          method: "post",
          data: {
            id: option.id
          },
          header: {
            Authorization: this.headerCode,
            "X-Requested-With": "xmlhttprequest"
          },
          success: res => {
          },
          fail: res => {
          console.log(res);
          if (res.errMsg) {
            wx.showToast({
              title: "请检查网络连接！",
              icon: "none",
              duration: 1500
            });
          }
        }
        });
      }
    });
  },
  mounted(){
     // 设置头
    wx.setNavigationBarTitle({
      title: "消息详情"
    });
  }
};
</script>

<style scoped>
@import url("~mpvue-wxparse/src/wxParse.css");
.NotificationDetails_die {
  padding: 20rpx;
  position: relative;
}
.NotificationDetails_die .header {
  display: flex;
  align-items: center;
}
.NotificationDetails_die .header img {
  width: 110rpx;
  height: 110rpx;
  border-radius: 50%;
  margin-right: 30rpx;
}
.NotificationDetails_die .header span {
  font-size: 30rpx;
  font-weight: 400;
  color: rgba(0, 0, 0, 1);
}
.NotificationDetails_die .content {
  margin: 0 20rpx;
}
.NotificationDetails_die .times {
  font-size: 22rpx;
  font-family: PingFang SC;
  font-weight: 400;
  color: rgba(153, 153, 153, 1);
  position: absolute;
  right: 10rpx;
  bottom: 10rpx;
}
</style>
